<template>
	<view class="bg">
		<view class="content">
		<u-navbar back-text="" slot="center" :autoBack="true" safeAreaInsetTop placeholder>
			<view slot="center" class="leftText"></view>
		</u-navbar>
		<view class="center">
			<view class="contacts">
				<view class="info">
					<image src="http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/images/user-real.svg" />
					<view class="comptitle">
						<view>{{enidentityList.cname}}</view>
						<view>
						{{enidentityList.cindustry?enidentityList.cindustry:'暂未添加'}}
						·{{enidentityList.cnature?enidentityList.cnature:''}}
						·{{enidentityList.csize?enidentityList.csize:''}}</view>
					</view>
				</view>
			</view>
			<view class="contentTitle">公司地址</view>
			<view class="address"><view>{{enidentityList.caddr}}</view><view>导航</view></view>
			<view class="contentTitle" v-if="enidentityList.cdescription">公司介绍</view>
			<view class="companycontent" v-if="enidentityList.cdescription">{{enidentityList.cdescription}}</view>
			<view class="contentTitle">工商信息</view>
			<view class="companyInfo">
				<view v-if="enidentityList.cname"><view>公司全称</view><view>{{enidentityList.cname}}</view></view>
				<view v-if="enidentityList.clegal"><view>法定代表人</view><view>{{enidentityList.clegal}}</view></view>
				<view v-if="enidentityList.cregistedCapital"><view>注册资本</view><view>{{enidentityList.cregistedCapital}}</view></view>
				<view v-if="enidentityList.createTime"><view>成立日期</view><view>{{enidentityList.createTime}}</view></view>
			</view>
			<view class="contentTitle">相关好活</view>
		</view>
		<view class="index">
			<scroll-view scroll-y="true" class="scroll-Y">
			  <view class="list" v-for="(rowitem,rowindex) in listrow" :key="rowindex">
				<view class="title dis-row poser" @click="NavInfoMsg(rowitem.id)" >
					  <text class="tips" v-if="rowitem.type ==1">置顶</text>
					  <view v-if="rowitem.titleName && rowitem.type ==1" style="text-indent: 2.7em;">{{cutstr(rowitem.titleName,65)}}</view>
					  <view v-if="rowitem.titleName && rowitem.type !=1" >{{cutstr(rowitem.titleName,65)}}</view>
				 </view>
			     <view class="cont" v-if="rowitem.workDesc"  @click="NavInfoMsg(rowitem.id)">{{cutstr(rowitem.workDesc,103)}}</view>
				  <view class="tag"  @click="NavInfoMsg(rowitem.id)">
						<view v-if="rowitem.salaryStr" class="t1">{{rowitem.salaryStr}}</view>
						<view v-if="rowitem.settlementStr">{{rowitem.settlementStr}}</view>
						<block v-if="rowitem.welfareNew">
							<view v-for="(childitem,childindex) in rowitem.welfareNew">{{childitem}}</view>
						</block>
				   </view>
				  <view class="info">
						<view class="left"  @click="NavInfoMsg(rowitem.id)">
							  <view class="top">
								<view class="name">{{rowitem.nickName?rowitem.nickName:'contactsName'}}</view>
								  <block v-if="rowitem.isEnterPrise == 0 && rowitem.isRealName == 1">
									  <image src="http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/images/user-real.svg" />
									  <view class="authMe" v-if="">实名认证</view>
								  </block>
									<block v-if="rowitem.isEnterPrise == 1 && rowitem.isRealName == 1">
									  <image src="http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/images/comp-real.svg" />
									  <view class="comp">企业认证</view>
								  </block>
							  </view>
							  <view class="addr">
								<u-icon name="map" color="#A1A1A1" size="13"></u-icon>
								{{rowitem.cityArea}} · {{rowitem.createTime}}
							  </view>
						</view>
						<view class="right">
						  <!-- <view class="t2">已发名片</view> -->
						  <view class="btn">立即联系</view>
						</view>
				  </view>
			  </view>
				<!-- <view class="list complist" v-for="(item, index) in 2" :key="index">
				  <view class="title">
					<text class="tips">置顶</text>
					<view>陕西西安未央区招木工、水电工</view>
				  </view>
				  <view class="cont"
					>轻轻松松月入过万，现有33层招钢筋大工，二把刀不要！！</view
				  >
				  <view class="tag">
					<view class="t1">350元/天 </view>
					<view>日结</view>
					<view>包吃包住 </view>
					<view>高温补贴 </view>
					<view>医疗保险 </view>
				  </view>
				  <view class="info">
					<view class="left">
					  <view class="top">
						<view class="name">中国建筑有限公司</view>
						<image src="http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/images/comp-real.svg" />
						<view class="comp">企业认证</view>
					  </view>
					  <view class="addr">
						<u-icon name="map" color="#A1A1A1" size="13"></u-icon>
						陕西西安 · 01-20 19:00:00
					  </view>
					</view>
					<view class="right">
					  <view class="t1">接通率高</view>
					  <view class="btn">立即联系</view>
					</view>
				  </view>
				</view> -->
			</scroll-view>
		</view>
		</view>
	</view>
</template>
<script>
	import store from '@/common/store.js'
	import Index from './index-model.js'
	let index=new Index();
	export default {
		data() {
			return {
				enidentityId:'',
				enidentityList:{},
				listrow:[]
			}
		},
		onLoad(opt) {
			this.enidentityId = opt.enidentity
			this.getenidentity(this.enidentityId)
			this.getRowList(this.enidentityId)
		},
		onPullDownRefresh() {
			setTimeout(function () {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		methods: {
			//查询企业信息
			getenidentity(enidentity) {
				let url="client/enterprise/info/detailById/"+enidentity
				index.getPublicUserMember({},url,'get',res=>{
					if(res.data.code == 200 && res.data.success){
						this.enidentityList = res.data.result
					}
				})
			},
			//查询企业发布的好活
			getRowList(enidentity) {
				let url="client/job/select/orders/"+enidentity
				let arr= [],welfares=[]
				this.listrow = []
				index.getPublicUserMember({},url,'get',res=>{
					if(res.data.code == 200 && res.data.success){
						arr = res.data.result
						if(arr.length>0){
						  for(let i=0;i<arr.length;i++){
						    arr[i].titleName = arr[i].address+'招'+arr[i].skills  //拼接地址+技能 = 列表标题
							if(arr[i].welfare){
								welfares=arr[i].welfare.split(',');
								for(let i=0;i<welfares.length;i++){
									if(welfares[i] == ''){
										welfares.splice(i,1)
									}
								}
								arr[i].welfareNew = welfares;
								//arr[i].welfareNew = arr[i].welfare.split(',')
							}else{
								arr[i].welfareNew = []
							}
							this.listrow.push(arr[i])
						  }
						}
					}else{
						this.listrow = []
					}
				})
			},
			cutstr(str, len) {
				var str_length = 0;
				var str_len = 0;
				var str_cut = new String();
				str_len = str.length;
				for (var i = 0; i < str_len; i++) {
					var a = str.charAt(i);
					str_length++;
					if (escape(a).length > 4) {
						//中文字符的长度经编码之后大于4  
						str_length++;
					}
					str_cut = str_cut.concat(a);
					if (str_length >= len) {
						str_cut = str_cut.concat("...");
						return str_cut;
					}
				}
				//如果给定字符串小于指定长度，则返回源字符串；  
				if (str_length < len) {
					return str;
				}
			},
			NavInfoMsg(value) {
				console.log(value,'===ttt====')
				if(!uni.getStorageSync('token')){
					index.navigate_to('../../pagesC/login/login')
					return false
				}
				if(!value||value==''){
					index.show_tips('企业信息异常')
					return false
				}
				let url = '../jobinfo/index?id='+value
				index.redirectto(url)
			},
		}
	}
</script>

<style lang="scss" scoped>
@import url("index.css");
@import url("@/static/css/publics.css");
::v-deep {
  .u-navbar--fixed {	  
	  background-image: url('http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/images/gb3.png');
	  background-size: 100%;
	  background-repeat: no-repeat;
    // background-image: linear-gradient(to bottom, #42cdff, #0288ff);
    & > view {
      background: transparent !important;
    }
    .leftText {
      color: #fff;
    }
  }
}
.bg{ background: #fff;}
.content{
	background-image: url('http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/images/gb3.png');
	background-size: 100%;
	background-repeat: no-repeat;
}

.center{
	padding: 0rpx 20rpx;
	.contentTitle{
		margin-top: 48rpx;
		margin-bottom: 24rpx;
		font-size: 36rpx;
		color: #424242;
		font-weight: bold;
	}
	.address{
		display: flex;
		font-size: 28rpx;
		view:nth-child(1){
			flex: 1;
			margin-right: 30rpx;
			color: #424242;
			line-height: 44rpx;
		}
		view:nth-child(2){
			width: 138rpx;
			height: 64rpx;
			line-height: 64rpx;
			text-align: center;
			border: 1px solid #0575ff;
			border-radius: 32rpx;
			color: #3D3D3D;
			margin-top: 14rpx;
		}
	}
	.companycontent{
		color: #424242;
		line-height: 44rpx;
		font-size: 28rpx;
	}
	.companyInfo{
		view{
			display: flex;
			text-align: left;
			color: #424242;
			line-height: 44rpx;
			margin-bottom: 20rpx;
			view:nth-child(1){
				width: 140rpx;
				margin-right: 24rpx;
			}
		}
	}
}
.contacts{
	.info{
		display: flex;
		image{
			width: 104rpx;
			height: 104rpx;
		}
		.comptitle{
			view:nth-child(1){
				font-size: 36rpx;
				line-height: 44rpx;
				color: #424242;
				font-weight: bold;
			}
			view:nth-child(2){
				font-size: 28rpx;
				color: #A1A1A1;
				margin-top: 16rpx;
			}
		}
	}
}

.index {
	background: #F3F3F3;
	padding-bottom: 0rpx;
	.complist{
		// background-image: url('http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/images/comp-bg.png');
		background-repeat: no-repeat!important;
		background-position: bottom left!important;
	}
    .list {
      padding: 20rpx 20rpx 0;
	  background: #fff;
	  margin-bottom: 20rpx;
     .title {
       display: flex;
     	flex-direction: row;
       // align-items: center;
       text {
     	 display: inline-block;
         background: #ff5964;height: 38rpx;line-height: 38rpx;text-align: center;
     	 position: absolute;left: 0rpx;top: 8rpx;
         color: #fff;
     	 width: 64rpx;
         font-size: 20rpx;
         // padding: 4rpx 10rpx;
         border-radius: 8rpx;
     		  // margin-right: 20rpx;
       }
       view {
		font-weight: 36rpx;
		font-weight: bold;
         
       }
     }
      .cont {
        margin: 20rpx 0;
        font-size: 24rpx;
        color: #424242;
      }
      .tag {
        display: flex;
      		flex-wrap: wrap;
        view {
          background: #f7f7f7;
          border-radius: 8rpx;
          font-size: 28rpx;
          padding: 10rpx;
          margin-right: 10rpx;
          color: #424242;
      		  margin-bottom: 10rpx;
        }
        .t1 {
          color: #ff5964;
        }
      }
      .info {
        padding-top: 20rpx;
        padding-bottom: 30rpx;
        margin-top: 20rpx;
        align-items: baseline;
        border-top: 0.5px solid #f0f0f0;
        display: flex;
        justify-content: space-between;
        .left {
          .top {
            display: flex;
            align-items: center;
            .name {
              color: #0f0f0f;
              font-weight: bold;
            }
            image {
              width: 28rpx;
              height: 28rpx;
			  margin-left: 14rpx;
			  margin-right: 10rpx;
            }
            .authMe {
              color: #a1a1a1;
              font-size: 24rpx;
            }
			.comp {
			  color: #d9a14e;
			  font-size: 24rpx;
			}
          }
          .addr {
            display: flex;
            color: #a1a1a1;
            font-size: 24rpx;
            margin-top: 10rpx;
            ::v-deep {
              .u-icon {
                margin-right: 14rpx;
              }
            }
          }
        }
        .right {
          display: flex;
          flex-direction: column;
          align-items: flex-end;
          .t1 {
            background: #ddffd5;
            color: #424242;
            font-size: 24rpx;
            border-radius: 24rpx;
            padding: 2rpx 10rpx;
          }
		  .t2 {
		    background: #E4F0FF;
		    color: #424242;
		    font-size: 24rpx;
		    border-radius: 24rpx;
		    padding: 2rpx 10rpx;
		  }
          .btn {
            height: 60rpx;
            line-height: 60rpx;
            width: 140rpx;
            text-align: center;
            color: #fff;
            border-radius: 8rpx;
            background: #0575ff;
            font-size: 28rpx;
          }
        }
      }
  }
}
</style>